package vocabularyhub.word.process.util;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import org.apache.log4j.Logger;

import vocabularyhub.io.impl.SimplestReader;
import vocabularyhub.word.model.IWord;
import vocabularyhub.word.mw.process.WordThesaurusProcessor;

public class GRERedBible {
    static Logger logger = Logger.getLogger(WordThesaurusProcessor.class);

    public static void main(String args[]) throws IOException {
        new GRERedBible().run();
    }

    public void run() throws IOException {
        File f1 = new File("contents\\redCore.txt");
        File f2 = new File("contents\\redCoreReverse.txt");
        List<IWord> wordList1 = new SimplestReader().parseWordListFile(f1);
        List<IWord> wordList2 = new SimplestReader().parseWordListFile(f2);

        logger.info(String.format("%d word in red core", wordList1.size()));
        logger.info(String.format("%d word in Reverse", wordList2.size()));

        Set<IWord> setUnion = new TreeSet<IWord>();
        setUnion.addAll(wordList1);
        setUnion.addAll(wordList2);
        Set<IWord> set1 = new TreeSet<IWord>(setUnion);
        Set<IWord> set2 = new TreeSet<IWord>(setUnion);

        set1.removeAll(wordList2);
        set2.removeAll(wordList1);

        logger.info(String.format("%d word in red core", wordList1.size()));
        logger.info(String.format("%d word in Reverse", wordList2.size()));

        logger.info(String.format("%d word Only in red core", set1.size()));
        logger.info(String.format("%d word Only in Reverse", set2.size()));
        logger.info(String.format("%d word in Join", setUnion.size()));

        /* uncomment the following line to write a new "redCoreJoin.txt" */
        // new SimplestWriter().writeToFile(new ArrayList<IWord>(setUnion),
        // new File(
        // "contents" + File.separator + "redCoreJoin.txt"));
    }

}
